/*
 * @lc app=leetcode.cn id=191 lang=typescript
 *
 * [191] 位1的个数
 */

// @lc code=start
function hammingWeight(n: number): number {
    return n
        .toString(2)
        .split("")
        .reduce((col, cur) => {
            if (cur === "1") return col + 1;
            return col;
        }, 0);
}
// @lc code=end
